<?php


class Plugin_ViewSetup extends Zend_Controller_Plugin_Abstract {

    protected $_oView;

    public function preDispatch(Zend_Controller_Request_Abstract $oRequest) {
	$sModuleName = $oRequest->getModuleName();

	$sLayoutPaths = ROOT_DIR . '/application/modules/' . $sModuleName.'/views/layouts';

	Zend_Layout::startMvc(array(
	    'layoutPath' => $sLayoutPaths,
	    'layout' => 'layouts'
	));

	$oViewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
	$oViewRenderer->init();
	$oView = $oViewRenderer->view;

	$oView->doctype('HTML4_STRICT');
	$oView->headMeta()->appendHttpEquiv('content-type', 'text/html;charset=utf-8');
	$oView->headTitle('Project Butter');

	// Add Module Specific View Helper(s)
	$sModuleViewHelperPath = ROOT_DIR . '/application/modules/' . $sModuleName . '/views/helpers';
	$sModuleViewHelperClassPrefix = ucwords($sModuleName) . '_View_Helper';
	$oView->addHelperPath($sModuleViewHelperPath, $sModuleViewHelperClassPrefix);

    }
}


